﻿using Autofac;
using Autofac.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ymatou.ServiceCenter.Common;
using Ymatou.ServiceCenter.Domain;
using Ymatou.ServiceCenter.Domain.IServices;

namespace Ymatou.ServiceCenter.Domain
{
    /// <summary>
    /// 服务容器，所有服务都统一从这个入口调用，方便服务的调用，及以后对IOC容器产品的替换等
    /// </summary>
    public static class ServiceHub
    {
        private static readonly IContainer Container;
        static ServiceHub()
        {
            ContainerBuilder builder = new ContainerBuilder();
            builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
            Container = builder.Build();
        }
        /// <summary>
        /// 配置服务
        /// </summary>
        public static IConfigService ConfigService
        {
            get
            {
                return Container.Resolve<IConfigService>();
            }
        }

        public static IServiceMetadataService ServiceMetadataService
        {
            get
            {
                return Container.Resolve<IServiceMetadataService>();
            }
        }
    }
}
